package com.chihihx.launcher.ui.fragment

import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.chihihx.launcher.BaseWallPaperFragment
import com.chihihx.launcher.MainActivity
import com.chihihx.launcher.bean.DateSettingDto
import com.chihihx.launcher.bean.LanguageDto
import com.nova.android.tvlauncher.R
import com.nova.android.tvlauncher.databinding.FragmentDateSettingHxtvBinding
import com.nova.android.tvlauncher.databinding.FragmentSplashHxtvBinding
import com.nova.android.tvlauncher.databinding.ItemDateSettingBinding
import com.nova.android.tvlauncher.databinding.ItemLanguageSettingBinding
import com_github_lib_base.base.BaseViewModel
import com_github_lib_base.ext.replaceChildFragment
import com_github_lib_base.ext.rv.addModels
import com_github_lib_base.ext.rv.setup
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

class DateSettingFragment : BaseWallPaperFragment<FragmentDateSettingHxtvBinding, BaseViewModel>() {

    override fun initView() {
        mBind.rvDate.setup(mutableListOf()) {
            addType(DateSettingDto::class, R.layout.item_date_setting)
            onBind {
                val itemBinding = getBinding<ItemDateSettingBinding>()
                val item = getModel<DateSettingDto>()
                itemBinding.tvName.text = item.title
                itemBinding.tvDesc.text = item.content
                if(item.content.isNullOrEmpty()){
                    itemBinding.tvDesc.isVisible = false
                }else  itemBinding.tvDesc.isVisible = true

                if(modelPosition==0){
                    itemBinding.switchBtn.isVisible = true
                    itemBinding.ivArrowRight.isVisible = false
                }else{
                    itemBinding.switchBtn.isVisible = false
                    itemBinding.ivArrowRight.isVisible = true
                }
            }
        }
        val list = mutableListOf<DateSettingDto>().apply {
            add(DateSettingDto("使用24小时制",""))
            add(DateSettingDto("时区","中国标准时间"))
        }
        mBind.rvDate.addModels(list)
    }
}